package com.ruoyi.hr.util;

import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.hr.domain.Events;
import com.ruoyi.hr.domain.salary.EmpSalary;
import com.ruoyi.hr.service.EventsService;
import com.ruoyi.system.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

public class utils {
    @Autowired
    private EventsService eventsService;

    public static List<EmpSalary> empSalaryList;

    /**
     * 获取当前年月日
     *
     * @return 年月日
     */
    public static String getDate() {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
        return df.format(new Date());
    }

    public void empQuit() {
        List<Events> events = this.getEvents();
    }

    public List<Events> getEvents() {
        List<Events> events = eventsService.findEvents(Long.parseLong("1523"), "all");
        return events;
    }

    public String timeConversion(String glwz) {

        return null;
    }

    public String specialCharacters(String characters) {

        return null;
    }

    public static Integer getArryZero(String text) {
        String[] arry = text.split(",");
        return Integer.parseInt(arry[0]);
    }

    public static boolean isInteger(String str) {
        Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
        return pattern.matcher(str).matches();
    }

    public static Map<String, Object> addAuthority(Map<String, Object> map) {
        SysUser user = ShiroUtils.getSysUser();
        map.put("depIDs", user.getDepIDs());
        map.put("isAdmin", user.getIsAdmin());
        return map;
    }


}
